﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MSXML2;//服务器的.Com组件
public partial class Net_Ajax : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string body="",link="",html="",str="",url="http://search.17173.com/bk.jsp?keyword=aa&submit=";
        str = Request.QueryString.ToString();
        if (str != "")
        {
            url = "http://search.17173.com/bk.jsp?"+str;
            url = Server.UrlDecode(url);
        }
        Response.Write(url);
        //新建xmlhttp对象
        MSXML2.XMLHTTP xmlhttp = new XMLHTTP();
        //xmlhttp.open("get", "http://www.baidu.com/s?wd=aa&cl=3", false, "", "");
        xmlhttp.open("get",url,false,"","");
        xmlhttp.setRequestHeader("Content-Type","text/html; charset=gb2312");
        xmlhttp.send(null);
        html=xmlhttp.responseText.ToString().Replace("/bk.jsp","/xml/Net_Ajax.aspx");//得到数据
        body = html.Substring(html.IndexOf("<BODY>"), (html.IndexOf("</BODY>") - html.IndexOf("<BODY>")));//从ＢＯＤＹ开始的地方截取　到ＢＯＤＹ结束
        link = html.Substring(0,html.IndexOf("<BODY>")).ToString();
        link = link.Substring(link.IndexOf("<link href="),link.LastIndexOf("type=\"text/css\""));
        Page.Header.InnerHtml= link;
        cont.InnerHtml =body ;

    }
}
